using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using SolanumSolstice_Windows.Mapping;
using SolanumSolstice_Windows.Buildings;
using SolanumSolstice_Windows.Units.Weapons;



namespace SolanumSolstice_Windows.Units
{
    public class Cop : Human
    {

        protected bool isCleansing;
        protected Building targetBuilding;

        public bool IsCleansing
        {
            get
            {
                return isCleansing;
            }
            set
            {
                isCleansing = value;
            }
        }

        public Cop(ContentManager content, Vector2 position)
            : base(content, position)
        {
            texture = content.Load<Texture2D>("Content\\Txtr\\Units\\Sprites\\mil_cop_sheet");
            hudTexture = content.Load<Texture2D>("Content\\Txtr\\Units\\HUD\\copHUD");
            this.hitPoints = 18;
            maxHitPoints = hitPoints;
            velocity = 1.0f;
            sightRadius = 5;
            attackPower = 2;
            unitClass = UnitClass.Military;
            isCleansing = false;

            //attackRadius = 128.0f;
            spawnCost = 8;
            timeCost = 8;


//            weapon = SubMachineGun(content);
            weapon = new Fist(content);
            attackRadius = weapon.AttackRadius;
        }

        public override void Update(GameTime gameTime, List<Unit> enemiesInRange, List<Unit> friendsInRange)
        {
            base.Update(gameTime, enemiesInRange, friendsInRange);

            if (isCleansing == true && targetReached == true && inBuilding == false)
            {
                targetBuilding.EnterBuilding(this);
            }

        }

        public override void SetTarget(Vector2 target)
        {
            base.SetTarget(target);

            isCleansing = false;
            targetBuilding = null;
        }

        public void SetCleansingTarget(Vector2 target, Building targetBuild)
        {
            SetTarget(targetBuild.Entrance);
            isCleansing = true;
            targetBuilding = targetBuild;
            
        }

        public override Object Clone()
        {
            Cop u = new Cop(this.content, this.position);

            u.weapon = this.weapon;
            u.hitPoints = this.hitPoints;
            u.maxHitPoints = this.maxHitPoints;
            u.recoveryTime = this.recoveryTime;
            u.initialRecoveryTime = this.initialRecoveryTime;
            u.position = this.position;
            u.velocity = this.velocity;
            u.sightRadius = this.sightRadius;
            u.attackRadius = this.attackRadius;
            u.attackPower = this.attackPower;
            u.isSelected = this.isSelected;
            u.isDead = this.isDead;
            u.isDying = this.isDying;
            u.isZombie = this.isZombie;
            u.inBuilding = this.inBuilding;
            u.isAttacking = this.isAttacking;
            u.actionSelected = this.actionSelected;
            u.actionReady = this.actionReady;
            u.rand = this.rand;
            u.actions = this.actions;
            u.currentActionIndex = this.currentActionIndex;
            u.targetReached = this.targetReached;
            u.direction = new Vector2(this.direction.X, this.direction.Y);
            u.unitClass = this.unitClass;

            u.isCleansing = this.isCleansing;
            u.targetBuilding = this.targetBuilding;

            u.timeCost = this.timeCost;
            u.spawnCost = this.spawnCost;

            return u;
        }

    }
}
